@extends('pc_admin.app')

@section('content')
<link rel="stylesheet" href="/css/pc-system/colleague-verifice.css">
<div class="mian-container">
    <div class="container-section colleague-verifice">
        {{--<form class="bar-form">
                <div class="inside-div">
                    <i class="icon iconfont icon-searsm01"></i>
                    <input type="text" class="bar-input" id="searchInput" placeholder="搜索" required="">
                </div>
        </form>--}}
        <div class="weui-cells">
            @foreach($list as $l)
                <div class="weui-cell">
                    <div class="weui-cell__hd"><img src="/img/one1.jpg"></div>
                    <div class="weui-cell__bd">
                        <p class="mar-bottom">{{getRegisterName($l->user_id)}}</p>
                        <p class="gray-color">{{$l->quote}}</p>
                    </div>
                    <div class="weui-cell__ft">
                        <p class="gray-color mar-bottom">{{$l->created_at}}</p>
                        <a href="javascript:void(0)" data-id="{{$l->id}}" class="a-btn refuse-btn">拒绝</a><a href="javascript:void(0)" data-id="{{$l->id}}" class="a-btn pass-btn">通过</a>
                    </div>
                </div>
            @endforeach
        </div>
    </div>
    {!! csrf_field() !!}
</div>
<script>
    $(document).ready(function () {

        $('.pass-btn').click(function () {
            var applyid = $(this).attr('data-id');
            var token = $('input[name=_token]').val();
            $.ajax({
                url:'/sysadmin/user/apply?_token='+token+'&is_agree=1',
                type:'post',
                dataType:'json',
                data:{'applyid':applyid},
                error: function (request) {
                    layer.msg('网络错误');
                },
                success: function (data) {
                    if (data.status == 'success') {
                        layer.msg(data.msg);
                        setTimeout(function(){ window.location.href=data.redirectUrl; }, 1000);
                    } else {
                        layer.msg(data.msg);
                    }
                },
            });
        });
        $('.refuse-btn').click(function () {
            var applyid = $(this).attr('data-id');
            var token = $('input[name=_token]').val();
            $.ajax({
                url:'/sysadmin/user/apply?_token='+token+'&is_agree=2',
                type:'post',
                dataType:'json',
                data:{'applyid':applyid},
                error: function (request) {
                    layer.msg('网络错误');
                },
                success: function (data) {
                    if (data.status == 'success') {
                        layer.msg(data.msg);
                        setTimeout(function(){ window.location.href=data.redirectUrl; }, 1000);
                    } else {
                        layer.msg(data.msg);
                    }
                },
            });
        });
    })
</script>
@endsection